/*
 * @Author: your name
 * @Date: 2021-01-21 15:47:54
 * @LastEditTime: 2021-01-28 10:05:41
 * @FilePath: \flutter_study\lib\pages\scaffold_demo.dart
*/

import 'package:flutter/material.dart';
import './list_demo.dart'; // ListView 模块
import './boxdecoration_demo.dart'; // BoxDecoration 模块
import './layout_demo.dart'; // 布局模块
import './sliver_demo.dart'; // Sliver 模块组件

class ScaffoldDemo extends StatefulWidget {
  @override
  _ScaffoldDemoState createState() => _ScaffoldDemoState();
}

class _ScaffoldDemoState extends State<ScaffoldDemo> {
  int _currentIndex = 0;
  @override
  Widget build(BuildContext context) {
    return DefaultTabController(
      length: 4,
      child: Scaffold(
        appBar: AppBar(
            title: Text(
              "ninghao".toUpperCase(),
            ),
            centerTitle: true,
            leading: IconButton(
              icon: Icon(Icons.menu),
              onPressed: () => print("leading Button is pressed"),
            ),
            actions: <Widget>[
              IconButton(
                icon: Icon(Icons.search),
                onPressed: () => print("search Button is pressed"),
              ),
            ],
            bottom: TabBar(
              unselectedLabelColor: Colors.grey.withOpacity(0.6),
              indicatorColor: Colors.yellow,
              indicatorSize: TabBarIndicatorSize.label,
              tabs: <Widget>[
                Tab(
                  icon: Icon(Icons.local_florist),
                ),
                Tab(
                  icon: Icon(Icons.change_history),
                ),
                Tab(
                  icon: Icon(Icons.directions_bike),
                ),
                Tab(
                  icon: Icon(Icons.accessibility),
                )
              ],
            )),
        body: TabBarView(
          children: <Widget>[
            ListViewDemo(),
            BoxDecorationDemo(),
            LayoutDemo(),
            CustomScrollViewDemo(),
          ],
        ),
        // drawer: Drawer(
        //   child: ListView(
        //     children: <Widget>[
        //       DrawerHeader(
        //         decoration: BoxDecoration(color: Colors.grey[500]),
        //         child: Text("Header"),
        //       ),
        //     ],
        //   ),
        // ),
        floatingActionButton: FloatingActionButton(
          child: Icon(Icons.add),
          onPressed: () => print("floatingActionButton is pressed"),
        ),
        floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
        bottomNavigationBar: BottomNavigationBar(
          items: <BottomNavigationBarItem>[
            BottomNavigationBarItem(
                icon: Icon(Icons.explore), label: 'Explore'),
            BottomNavigationBarItem(
                icon: Icon(Icons.history), label: 'History'),
            BottomNavigationBarItem(icon: Icon(Icons.list), label: 'List'),
            BottomNavigationBarItem(icon: Icon(Icons.person), label: 'My'),
          ],
          type: BottomNavigationBarType.fixed,
          selectedItemColor: Colors.deepPurple,
          currentIndex: _currentIndex,
          onTap: (int index) {
            setState(() {
              _currentIndex = index;
            });
          },
        ),
      ),
    );
  }
}
